<template>
  <div class="app-container">
    <div class="function-app-container">
      <!-- 页面标题 -->
      <div class="page-header">
        <h2 class="page-title">资产管理</h2>
      </div>
      
      <!-- 功能卡片区域 -->
      <div class="function-cards">
        <div class="function-card" v-for="(item, index) in functionList" :key="index">
          <div class="card-icon">
            <div class="sms-icon" v-if="item.type === 'sms'">
              <div class="envelope">
                <div class="envelope-body"></div>
                <div class="envelope-flap"></div>
                <div class="message-lines">
                  <div class="line line-1"></div>
                  <div class="line line-2"></div>
                  <div class="line line-3"></div>
                </div>
              </div>
            </div>
            <i :class="item.icon" :style="{ color: item.iconColor }" v-else></i>
          </div>
          <div class="card-content">
            <h3 class="card-title">{{ item.title }}</h3>
            <p class="card-description">{{ item.description }}</p>
            <div class="card-actions">
              <el-button 
                type="primary" 
                size="small" 
                icon="el-icon-shopping-cart-2"
                @click="handlePurchase(item)"
                class="action-btn purchase-btn"
              >
                购买
              </el-button>
              <el-button 
                type="default" 
                size="small" 
                icon="el-icon-user"
                @click="handleManage(item)"
                class="action-btn manage-btn"
              >
                进入管理
              </el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "FunctionApp",
  data() {
    return {
      functionList: [
        {
          id: 1,
          title: "短信管理",
          description: "短信统计、短信购买",
          icon: "el-icon-message-solid",
          iconColor: "#ff6b35",
          type: "sms"
        }
        // 可以在这里添加更多功能卡片
      ]
    }
  },
  methods: {
    // 购买功能
    handlePurchase(item) {
      this.$modal.msgInfo(`正在跳转到${item.title}购买页面...`)
      // 这里可以添加购买逻辑
      console.log('购买功能:', item)
    },
    
    // 进入管理功能
    handleManage(item) {
      this.$modal.msgInfo(`正在进入${item.title}管理页面...`)
      // 这里可以添加管理页面跳转逻辑
      console.log('管理功能:', item)
    }
  }
}
</script>

<style scoped>
.function-app-container {
  padding: 20px;
  background-color: #ffffff;
  min-height: calc(100vh - 84px);
}

.page-header {
  margin-bottom: 30px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #303133;
  margin: 0;
}

.function-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.function-card {
  background: #ffffff;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  padding: 24px;
  width: 320px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
}

.function-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.card-icon {
  margin-bottom: 16px;
}

.card-icon i {
  font-size: 48px;
  display: block;
}

/* 自定义短信图标样式 */
.sms-icon {
  width: 48px;
  height: 48px;
  position: relative;
}

.envelope {
  width: 100%;
  height: 100%;
  position: relative;
}

.envelope-body {
  width: 40px;
  height: 28px;
  background-color: #ff6b35;
  border-radius: 4px;
  position: absolute;
  top: 10px;
  left: 4px;
}

.envelope-flap {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 14px solid #ff6b35;
  position: absolute;
  top: 10px;
  left: 4px;
  transform-origin: bottom;
  transform: rotate(180deg);
}

.message-lines {
  position: absolute;
  top: 18px;
  left: 8px;
  width: 32px;
  height: 12px;
}

.line {
  height: 2px;
  background-color: #ffffff;
  margin-bottom: 2px;
  border-radius: 1px;
}

.line-1 {
  width: 28px;
}

.line-2 {
  width: 24px;
}

.line-3 {
  width: 20px;
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: #303133;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.card-description {
  font-size: 14px;
  color: #606266;
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.card-actions {
  display: flex;
  gap: 12px;
}

.action-btn {
  flex: 1;
  height: 32px;
  font-size: 13px;
  border-radius: 4px;
}

.purchase-btn {
  background-color: #409eff;
  border-color: #409eff;
  color: #ffffff;
}

.purchase-btn:hover {
  background-color: #66b1ff;
  border-color: #66b1ff;
}

.manage-btn {
  background-color: #ffffff;
  border-color: #dcdfe6;
  color: #606266;
}

.manage-btn:hover {
  background-color: #ecf5ff;
  border-color: #b3d8ff;
  color: #409eff;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .function-cards {
    flex-direction: column;
    align-items: center;
  }
  
  .function-card {
    width: 100%;
    max-width: 400px;
  }
}

@media (max-width: 480px) {
  .function-app-container {
    padding: 15px;
  }
  
  .function-card {
    padding: 20px;
  }
  
  .card-actions {
    flex-direction: column;
  }
  
  .action-btn {
    width: 100%;
  }
}
</style>
